<%--
  Created by IntelliJ IDEA.
  User: Sun_jl
  Date: 2021/9/9
  Time: 11:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>页面</title>
    <script type="text/javascript" src="./jquery/jquery-2.1.1.min.js"></script>
    <base href="http://${pageContext.request.serverName }:${pageContext.request.serverPort }${pageContext.request.contextPath }/"/>
</head>
<script type="text/javascript">
    $(function () {
        $("#btn").click(function () {
            var student = {
                "stuId": 5,
                "stuName":"tom",
                "address": {
                    "province": "广东",
                    "city": "深圳"
                },
                "subList": [
                    {
                        "subName": "JavaSE",
                        "subScore": 100
                    },
                    {
                        "subName": "SSM",
                        "subScore": 99
                    }
                ],
                "map": {
                    "k1":"v1",
                    "k2":"v2"
                }

            };
            // 将JSON对象转换为JSON字符串
            var requestBody = JSON.stringify(student);
            $.ajax({
                "url":"send/compose/object.json",
                "type":"post",
                "data":requestBody,
                "contentType":"application/json;charset=UTF-8",
                "dataType":"json",
                "success":function(response){
                    console.log(response);
                },
                "error":function(response){
                    console.log(response);
                }
            });
        })
    })
</script>
<body>
    <h1>哈哈哈哈</h1>
    <a href="${pageContext.request.contextPath}/hello/haha.html">first</a>
    <button id="btn">按钮</button>
</body>
</html>
